From 078efeb8b51930852d0fbc3cbf22a0252a1de4c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pablo=20Ari=C3=B1o=20Mu=C3=B1oz?= Date: Tue, 25 Feb 2025 16:54:16 +0100 Subject: [PATCH] Simplified the code, removed checkbox and moved section further down MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Pablo Ariño Muñoz --- src/gui/generalsettings.cpp | 36 ++++++++---------------------------- src/gui/generalsettings.h | 1 - src/gui/generalsettings.ui | 26 +++++++++++++------------- src/libsync/configfile.cpp | 21 --------------------- src/libsync/configfile.h | 2 -- 5 files changed, 21 insertions(+), 65 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index addcada5a..130770223 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -247,8 +247,7 @@ GeneralSettings::GeneralSettings(QWidget *parent) connect(_ui->stopExistingFolderNowBigSyncCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); connect(_ui->newExternalStorage, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); connect(_ui->moveFilesToTrashCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); - connect(_ui->remotePollIntervalSpinBox, static_cast(&QSpinBox::valueChanged), this, &GeneralSettings::slotRemotePollIntervalChanged); - connect(_ui->remotePollIntervalCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotRemotePollIntervalCheckBoxToggled); + connect(_ui->remotePollIntervalSpinBox, &QSpinBox::valueChanged, this, &GeneralSettings::slotRemotePollIntervalChanged); #ifndef WITH_CRASHREPORTER _ui->crashreporterCheckBox->setVisible(false); #endif @@ -330,12 +329,9 @@ void GeneralSettings::loadMiscSettings() _ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage()); _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); - - bool hasCustomInterval = cfgFile.hasRemotePollInterval(); - _ui->remotePollIntervalCheckBox->setChecked(hasCustomInterval); + ; auto interval = cfgFile.remotePollInterval(); _ui->remotePollIntervalSpinBox->setValue(static_cast(interval.count() / 1000)); - _ui->remotePollIntervalSpinBox->setEnabled(hasCustomInterval); } #if defined(BUILD_UPDATER) @@ -654,31 +650,15 @@ void GeneralSettings::customizeStyle() #endif } -void GeneralSettings::slotRemotePollIntervalCheckBoxToggled(bool checked) { - _ui->remotePollIntervalSpinBox->setEnabled(checked); // Enable/disable the spin box - - ConfigFile cfgFile; - - if (checked) { - slotRemotePollIntervalChanged(_ui->remotePollIntervalSpinBox->value()); - } else { - // Reset to default interval when unchecked - cfgFile.resetRemotePollInterval(); - - // Update the spinbox with the default value - auto interval = cfgFile.remotePollInterval(); - _ui->remotePollIntervalSpinBox->setValue(static_cast(interval.count() / 1000)); - } -} void GeneralSettings::slotRemotePollIntervalChanged(int seconds) { - if (_currentlyLoading) return; - - if (_ui->remotePollIntervalCheckBox->isChecked()) { - ConfigFile cfgFile; - std::chrono::milliseconds interval(seconds * 1000); - cfgFile.setRemotePollInterval(interval); + if (_currentlyLoading) { + return; } + + ConfigFile cfgFile; + std::chrono::milliseconds interval(seconds * 1000); + cfgFile.setRemotePollInterval(interval); } } // namespace OCC diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index 30d02cdf3..7868c4899 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -60,7 +60,6 @@ private slots: void loadMiscSettings(); void slotShowLegalNotice(); void slotRemotePollIntervalChanged(int seconds); - void slotRemotePollIntervalCheckBoxToggled(bool checked); #if defined(BUILD_UPDATER) void slotUpdateInfo(); void slotUpdateChannelChanged(); diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index 1d79bd1f3..0662b63ac 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -185,11 +185,22 @@ + + + + + + + Move removed files to trash + + + + - + Server poll interval @@ -201,7 +212,7 @@ 30 - 3600 + 999999 1 @@ -230,17 +241,6 @@ - - - - - - Move removed files to trash - - - - - diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 6adb8c2e2..1efd01e5d 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -1315,25 +1315,4 @@ void ConfigFile::setDiscoveredLegacyConfigPath(const QString &discoveredLegacyCo _discoveredLegacyConfigPath = discoveredLegacyConfigPath; } -bool ConfigFile::hasRemotePollInterval(const QString &connection) const -{ - QString con(connection); - if (connection.isEmpty()) - con = defaultConnection(); - - QSettings settings(configFile(), QSettings::IniFormat); - settings.beginGroup(con); - - return settings.contains(QLatin1String(remotePollIntervalC)); -} - -void ConfigFile::resetRemotePollInterval(const QString &connection) { - QString con(connection); - if (connection.isEmpty()) - con = defaultConnection(); - - std::chrono::milliseconds defaultInterval(DEFAULT_REMOTE_POLL_INTERVAL); - setRemotePollInterval(defaultInterval, con); // Use existing method -} - } diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index bf6be3548..f38fba1f1 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -153,8 +153,6 @@ public: [[nodiscard]] bool useNewBigFolderSizeLimit() const; [[nodiscard]] bool confirmExternalStorage() const; void setConfirmExternalStorage(bool); - [[nodiscard]] bool hasRemotePollInterval(const QString &connection = QString()) const; - void resetRemotePollInterval(const QString &connection = QString()); /** If we should move the files deleted on the server in the trash */ [[nodiscard]] bool moveToTrash() const; -- 2.30.2